
//
//  DLIncomeView.m
//  delongzhitou
//
//  Created by Mr.Wang on 2018/12/18.
//  Copyright © 2018 delongzhitou. All rights reserved.
//

#import "DLIncomeView.h"

@interface DLIncomeView ()

@property (nonatomic, strong) UILabel *moneyLabel;
@end


@implementation DLIncomeView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self layoutSubControls];
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}
- (void) setMoney:(CGFloat)money {
    _money = money;
//    NSString *moneyStr = @"";
//    if (money > 0) {
//        self.moneyLabel.textColor = [UIColor redColor];
//        moneyStr = [NSString stringWithFormat:@"+%.2f元", self.money];
//    } else {
//        self.moneyLabel.textColor = [UIColor greenColor];
//        moneyStr = [NSString stringWithFormat:@"-%.2f元", self.money];
//    }
//    self.moneyLabel.text = moneyStr;
    
    if (money >= 0) {
        self.moneyLabel.textColor = [UIColor redColor];
    } else {
        self.moneyLabel.textColor = [UIColor greenColor];
    }
    self.moneyLabel.text = [NSString stringWithFormat:@"%.2f元", money];
}
- (void) layoutSubControls {
    
    UILabel *moneyLabel = [UILabel new];
    moneyLabel.frame = self.bounds;
    moneyLabel.text = @"0.00元";
    moneyLabel.textColor = [UIColor redColor];
    moneyLabel.textAlignment = NSTextAlignmentCenter;
    moneyLabel.font = kBoldFont(24);
    [self addSubview:moneyLabel];
    self.moneyLabel = moneyLabel;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
